module EmployeeCertificateQuery
  def find_will_valid_certificates_by days
    EmployeeCertificate.where(state: 'normal')
                         .where("recheck_time <= '#{days.to_i.from_now.to_date}' and valid_end > '#{Time.now.to_date}'")
  end

  def query_will_valid_certificates begin_time, end_time
    EmployeeCertificate.where("valid_end >= ? and valid_end <= ?", begin_time, end_time)
  end
end
